<div class="page-container">
    <h1>特征编码</h1>
    
    <!-- API说明 -->
    <div class="api-docs">
        <h3>API接口说明</h3>
        <div class="api-item">
            <h4>获取特征编码</h4>
            <p>接口地址：/faceapi/v1/recognizeEncoding</p>
            <p>返回格式：JSON</p>
            <p>请求方式：POST</p>
            <p>请求示例：</p>
            <pre>
curl -X POST /faceapi/v1/recognizeEncoding 
-H "Authorization: your_token_here" 
-F "imgFile=@image.jpg"</pre>
            
            <p>请求参数说明：</p>
            <table class="api-table">
                <tr>
                    <th>名称</th>
                    <th>类型</th>
                    <th>必填</th>
                    <th>说明</th>
                </tr>
                <tr>
                    <td>imgFile</td>
                    <td>file</td>
                    <td>是</td>
                    <td>图片文件，支持jpg/png格式</td>
                </tr>
                <tr>
                    <td>Authorization</td>
                    <td>string</td>
                    <td>是</td>
                    <td>登录获取的token，需要在请求头中传递</td>
                </tr>
            </table>

            <p>返回参数说明：</p>
            <table class="api-table">
                <tr>
                    <th>名称</th>
                    <th>类型</th>
                    <th>说明</th>
                </tr>
                <tr>
                    <td>success</td>
                    <td>boolean</td>
                    <td>请求是否成功</td>
                </tr>
                <tr>
                    <td>code</td>
                    <td>integer</td>
                    <td>状态码，200表示成功</td>
                </tr>
                <tr>
                    <td>msg</td>
                    <td>string</td>
                    <td>状态描述</td>
                </tr>
                <tr>
                    <td>data.encoding</td>
                    <td>array</td>
                    <td>128维特征向量</td>
                </tr>
            </table>

            <p>JSON返回示例：</p>
            <pre>
{
    "success": true,
    "code": 200,
    "msg": "编码完成",
    "data": {
        "encoding": [-0.0854, 0.1257, ...]  // 128维向量
    }
}</pre>
        </div>

        <!-- <div class="api-item">
            <h4>2. 编码对比</h4>
            <p>接口地址：/faceapi/v1/recognizeCompareEncoding</p>
            <p>返回格式：JSON</p>
            <p>请求方式：POST</p>
            <p>请求示例：</p>
            <pre>
curl -X POST /faceapi/v1/recognizeCompareEncoding 
-H "Content-Type: application/json"
-d '{
    "encodings": [[0.1, 0.2, ...], [0.3, 0.4, ...]],
    "encoding": [0.1, 0.2, ...],
    "tolerance": 0.5
}'</pre>
            
            <p>请求参数说明：</p>
            <table class="api-table">
                <tr>
                    <th>名称</th>
                    <th>类型</th>
                    <th>必填</th>
                    <th>说明</th>
                </tr>
                <tr>
                    <td>encodings</td>
                    <td>array</td>
                    <td>是</td>
                    <td>编码列表，每个元素为128维向量</td>
                </tr>
                <tr>
                    <td>encoding</td>
                    <td>array</td>
                    <td>是</td>
                    <td>待比较的编码，128维向量</td>
                </tr>
                <tr>
                    <td>tolerance</td>
                    <td>float</td>
                    <td>否</td>
                    <td>相似度阈值，默认0.5</td>
                </tr>
            </table>

            <p>返回参数说明：</p>
            <table class="api-table">
                <tr>
                    <th>名称</th>
                    <th>类型</th>
                    <th>说明</th>
                </tr>
                <tr>
                    <td>success</td>
                    <td>boolean</td>
                    <td>请求是否成功</td>
                </tr>
                <tr>
                    <td>code</td>
                    <td>integer</td>
                    <td>状态码，200表示成功</td>
                </tr>
                <tr>
                    <td>msg</td>
                    <td>string</td>
                    <td>状态描述</td>
                </tr>
                <tr>
                    <td>data.compare_result</td>
                    <td>array</td>
                    <td>比较结果列表，true表示相似度在阈值内</td>
                </tr>
            </table>

            <p>JSON返回示例：</p>
            <pre>
{
    "success": true,
    "code": 200,
    "msg": "返回比较结果 [True] or [False]",
    "data": {
        "compare_result": [true, false]
    }
}</pre>
        </div> -->
    </div>

    <div class="function-group">
        <div class="upload-area" id="encodingUpload">
            <input type="file" id="encodingFile" accept="image/*" style="display: none;">
            <div>点击或拖拽图片到此处</div>
            <img id="encodingPreview" class="preview-image" style="display: none;">
        </div>
        <div class="button-group">
            <div class="test-button-group">
                <button onclick="showTestImageSelect('encoding')" class="test-button">
                    <i class="fas fa-vial"></i> 加载测试图片
                </button>
                <div id="encodingTestSelect" class="test-select-dropdown">
                </div>
            </div>
            <button onclick="getEncoding()">获取特征编码</button>
        </div>
        <div class="loading" id="encodingLoading" style="display: none;">处理中...</div>
        <div class="result-area" id="encodingResult"></div>
    </div>
</div> 